package com.ryl.yomall.activity.service.impl;

import com.ryl.yomall.activity.service.SecKillGoodsService;
import com.ryl.yomall.model.activity.SeckillGoods;
import com.ryl.yomall.model.common.constant.RedisConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Date 19:50
 * @Author ryl
 */
@Component
public class SecKillGoosServiceImpl implements SecKillGoodsService {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public List<SeckillGoods> list() {
        List values = redisTemplate.opsForHash ( ).values ( RedisConst.SECKILL_GOODS );
        return values;
    }

    @Override
    public SeckillGoods getSeckillGoods(Long skuId) {
        return (SeckillGoods) redisTemplate.opsForHash().
                get(RedisConst.SECKILL_GOODS,skuId.toString());
    }
}
